﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PracticeAzure.Website.Shared;

namespace PracticeAzure.Website.Models
{
    public abstract class PagedViewModel
    {
        public string Name { get; set; }

        public long Count { get; set; }

        public int Page { get; set; }

        public int Start
        {
            get
            {
                return (Page - 1) * GlobalConfiguration.PageSize + 1;
            }
        }

        public int End
        {
            get
            {
                var result = Start + GlobalConfiguration.PageSize - 1;
                return result > Count ? (int)Count : result;
            }
        }


        public bool AllowPrevious
        {
            get
            {
                return Start > 1;
            }
        }

        public bool AllowNext
        {
            get
            {
                return End < Count;
            }
        }
    }
}